<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css" media="screen">@import "style.css";</style>

<title> VideoExpress - PHP Projet</title>
<script type="text/javascript" src="js/TJK_ToggleDL.js"></script>
<SCRIPT TYPE="text/javascript">

function popupform(myform, windowname)
{
if (! window.focus)return true;
window.open('', windowname, 'height=500,width=550,scrollbars=yes');
myform.target=windowname;
return true;
}

</SCRIPT>
</head>

<body onload="TJK_ToggleDL()">
<div class="center">
<div class="outer" id="outer">
<div class="outer_l">
<div class="outer_r">

<!--ENTETE & MENU-->
<?php 
include ("Outils.inc");
banniere("VideoExpress","Nguyen Tat Son Tung");
?>
<!--FIN ENTETE & MENU-->


<!--CONTENT-->
<div class="wrap main_content_max_max" id="main_content">
<div class="content">
<table class="blog" cellpadding="0" cellspacing="0">
<tr><td valign="top"><div>
		
<table class="contentpaneopen"><tr>
<td class="contentheading" width="100%">RESULTATS DE LA RECHERCHE</td></tr></table>
<table class="contentpaneopen"><tr><td valign="top" colspan="2">
<?php
include ("connect.php");
$Titre=$_POST["Titre"];
$Support=$_POST["Support"];
$Statut=$_POST["Statut"];
$Genre=$_POST["Genre"];
$Realisateur=$_POST["Realisateur"];
$Acteur=$_POST["Acteur"];
$req="SELECT *"
."FROM `films`";
	
if (isset( $_POST["Titre"] )) {
	$mots = explode(" ", $_POST["Titre"]);
	$req.="where";
	foreach ( $mots as $mot ){
		if (isset($ajouteAnd)){
		$req.="and";
		}
	$req.=" `Titre` like '%".$mot."%' ";
	$ajouteAnd=1;
	}
}
if ( $_POST["Support"] != "Indifferent" ){
	if (!isset( $_POST["Titre"] )) {
	$req.="where";
	} else {
	$req.="and";}
$req.="`NoFilm` IN (SELECT `f`.`NoFilm`"
	."FROM `cassettes` `c`, `films` `f`"
	."WHERE `f`.`NoFilm` = `c`.`NoFilm`"
	."AND `c`.`Support` LIKE '$Support')";
}
if ( $_POST["Statut"] != "Indifferent" ){
	if (!isset( $_POST["Titre"] ) && ($_POST["Support"] == "Indifferent")) {
	$req.="where";
	} else {
	$req.="and";}
$req.="`NoFilm` IN (SELECT `f`.`NoFilm`"
	."FROM `cassettes` `c`, `films` `f`"
	."WHERE `f`.`NoFilm` = `c`.`NoFilm`"
	."AND `c`.`Statut` LIKE '$Statut')";
}

if ( $_POST["Genre"] != "Indifferent" ){
	if (!isset( $_POST["Titre"] ) && ($_POST["Support"] == "Indifferent") && ($_POST["Statut"] == "Indifferent")) {
	$req.="where";
	} else {
	$req.="and";}
$req.=" `Genre` like '".$_POST['Genre']."'";
}

if ( $_POST["Realisateur"] != "Indifferent" ){
	if (!isset( $_POST["Titre"] ) && ($_POST["Support"] == "Indifferent") && ($_POST["Statut"] == "Indifferent") && ($_POST["Genre"] == "Indifferent")){
	$req.="where";
	} else {
	$req.="and";}
$req.=" `Realisateur` like '".$_POST['Realisateur']."'";
}

if ( $_POST["Acteur"] != "Indifferent" ){
	if (!isset( $_POST["Titre"] ) && ($_POST["Support"] == "Indifferent") && ($_POST["Statut"] == "Indifferent") && ($_POST["Genre"] == "Indifferent") && ($_POST["Realisateur"] == "Indifferent")) {
	$req.="where";
	} else {
	$req.="and";}
$req.="`NoFilm` IN (SELECT `f`.`NoFilm`"
	."FROM `acteurs` `a`, `films` `f`"
	."WHERE `f`.`NoFilm` = `a`.`NoFilm`"
	."AND `a`.`Acteur` LIKE '$Acteur')";
}	
	
	
$resul = DB_execSQL($req,$serv);
$count = mysql_num_rows($resul);
if ( $count != 0 ){



echo '<img src="images/Search.png"><br \>';
echo '<dl id="TJK_DL">';
echo '<div class="jl_table">
  	<table cellpadding="3" cellspacing="0" border="1">
  	<tr class="sectiontableheader">
	<td><font size="2">NoFilm</font></td>
	<td><font size="2">Titre</font></td>
	<td><font size="2">R�alisateur</font></td>
	<td><font size="2">Statut</font></td>
	<td><font size="2">D�tails</font></td>
      <td><font size="2">------</font></td>
	</tr>';
while ($film = mysql_fetch_object($resul)){


echo "<TR><TD><h2>".$film->NoFilm."</TD><br \>"
	."<TD><h2>".$film->Titre."</TD><br \>"
	."<TD><h2>".$film->Realisateur."</TD><br \>"
	."<TD><h2>";
	
	$req1="SELECT *"
	."FROM `cassettes`"
	."WHERE `NoFilm` LIKE '$film->NoFilm' ";
	$res1 = mysql_query($req1,$serv);
	while ( $cassette = mysql_fetch_object($res1)){
	echo " ".$cassette->Support."/".$cassette->Statut."<br \> ";
	}
	echo "</font></TD><br \>";

echo "<TD><font size='2'>"
	."<DT><font color='#FFF'>INFOS</font></DT>"
	."<DD><br \>"
	."<h2><b><u>Nationalit�</u></b> : ".$film->Nationalite."<br \>"
	."<h2><b><u>Couleur</u></b> : ".$film->Couleur."<br \>"
	."<h2><b><u>Genre</u></b> : ".$film->Genre."<br \>"
	."<h2><b><u>Duree</u></b> : ".$film->Duree."<br \>"
	."<h2><b><u>Ann�e</u></b> : ".$film->Annee."<br \>"
	."<h2><b><u>Synopsis</u></b> : ".$film->Synopsis."<br \>"
	."<h2><b><u>Acteurs</u></b> :<br \>";
	

	$req2="SELECT *"
	."FROM `acteurs`" 
	."WHERE `NoFilm` LIKE '$film->NoFilm'";

	$res2 = mysql_query($req2,$serv);
	while ( $acteur = mysql_fetch_object($res2)){
	echo "".$acteur->Acteur.", ";
	}

echo "</DD><br \></font></TD>
	<TD><div><form method='POST' action='AjoutSelection.php' 
   onSubmit=\"popupform(this, 'join')\">
	<input type='hidden' name='NoFilm' value='$film->NoFilm'>
	<input type='image' src='images/Insert-icon.png' alt='submit' name='submit' title='Ajouter dans le Panier'>
	</form></div>
	</TR>";

}
echo "</table></div></dl>";

echo "<table><tr><td></tr>
	<tr><td>
	<div><form method='POST' action='VoirSelection.php' onSubmit=\"popupform(this, 'join')\">
	<input type='image' src='images/info.png' alt='submit' name='submit' title='Voir le Panier'><font size='2'> Voir Selection</font>
	</form></div></td>
	<td><td><td><td>
	</tr></table>";

} else {
echo '<img src="images/ErrorCircle.png"> <br \>';
echo "<font size='2'> Desole , Ce film n'a pas trouv�</font>";
}
?>
</td></tr></table>

<span class="article_separator">&nbsp;</span>

</div></td></tr></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--FIN CONTENT-->

<!-- PIED -->
<?php include ("inc/inc-pied.php"); ?>
<!-- FIN - PIED --> 
</body>
</html>